const http = require('http');
const { URL } = require('url');

const server = http.createServer((req, res) => {
    const url = req.url;
    const urlObj = new URL('http://localhost' + url);
    const cbName = urlObj.searchParams.get('cb');
    const data = [{name: 'dsadsd'}, {name: '李华'}];
    res.setHeader('Access-Control-Allow-Origin', '*');
    res.setHeader('Content-Type', 'application/javascript');
    console.log(cbName);
    res.write(`${cbName}(${JSON.stringify(data)})`);
    res.end();
});
server.on('listening', () => {
    console.log('listening');
})
server.listen(443, '127.0.0.1');